<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">

		<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
		Remove this if you use the .htaccess -->
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

		<title>Joinway Platform</title>
		<meta name="description" content="">
		<meta name="author" content="Administrator">

		<link rel="stylesheet" type="text/css" href="/static/jquery-easyui/1.4.1/themes/default/easyui.css">
    	<link rel="stylesheet" type="text/css" href="/static/jquery-easyui/1.4.1/themes/icon.css">
    	<link rel="stylesheet" type="text/css" href="/static/jquery-easyui/themes/icon.css">
    	<link rel="stylesheet" type="text/css" href="/static/jquery-easyui/1.4.1/themes/color.css">
    	<link rel="stylesheet" type="text/css" href="/static/css/admin.css">
   		<link rel="stylesheet" type="text/css" href="resources/css/index.css"/>
   		
   		<script type="text/javascript" src="/static/jquery/2.1.1/jquery.min.js"></script>
		<script type="text/javascript" src="/static/jquery-easyui/1.4.1/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="/static/jquery-easyui/1.4.1/locale/easyui-lang-zh_CN.js"></script>
   		<script type="text/javascript" src="/static/jquery/plugins/jquery.blockUI-2.7.js"></script>
   		<script type="text/javascript" src="/static/jquery/plugins/jquery.jrumble-1.3.min.js"></script>
		<script type="text/javascript" src="/static/commons/admin.js"></script>
<script type="text/javascript">
$(function() {
	$('#name').textbox({
		width: 340,
		height: 40,
		icons: [{
			iconCls: 'icon-clear',
			handler: function(e){
				$(e.data.target).textbox('clear');
			}
		}],
		buttonAlign: 'left',
		buttonIcon: 'icon-man'
	});
	$('#name').textbox('textbox').bind('keydown', function(e){
		//console.log(e.keyCode);
		if (e.keyCode == 13){
			$('#password').textbox('textbox').focus();
		}
	});
	
	$('#password').textbox({
		width: 340,
		height: 40,
		icons: [{
			iconCls: 'icon-clear',
			handler: function(e){
				$(e.data.target).textbox('clear');
			}
		}],
		buttonAlign: 'left',
		buttonIcon: 'icon-lock'
	});
	
	$('#password').textbox('textbox').bind('keydown', function(e){
		//console.log(e.keyCode);
		if (e.keyCode == 13){
			//console.log('clicked enter');
			login();
		}
	});
	
	$('#password').textbox('button').bind('focus', function(e){
		$('#password').textbox('textbox').focus();
	});
	
	$('#name').textbox('textbox').focus();
	
	$('table').jrumble({
		x: 5,
		y: 0,
		rotation: 0
	});
});
	
function login(){
	$('#error').text('');
	
	var form = new Object();
	form.name = $('#name').val();
	form.password = $('#password').val();
	
	//console.log(form);
	blockUI('正在登录...');
	$.ajax({
		type : "post",
		url : 'login.json',
		data : form,
		success : function(data) {
			//unblockUI(200);
			
			if(data.code == 0){
				//console.log(data.userId);
				window.location.href = 'main.dox';
			}else{
				$('#error').text('用户名或密码错误');
				$('table').trigger('startRumble');
				setTimeout(function(){$('table').trigger('stopRumble')}, 500);
			}
		},
		error: function(){
			unblockUI();
			$('#error').text('网络错误');
		}
	});
}
</script>
	</head>

<body>
<header>
	<h1>Joinway Platform</h1>
</header>

<section>
<article>
	<table>
		<tr>
			<td></td>
			<td id="error" class="error">&nbsp;</td>
		</tr>
		<tr>
			<td class="text">用户名</td>
			<td class="input"><input id="name" name="name" type="text" class="easyui-textbox" tabindex="0"/></td>
			<td class="login" rowspan="2"><img alt="登录" class="login_btn" src="resources/images/login.jpg" onclick="login();"></td>
		</tr>
		<tr>
			<td class="text">密码</td>
			<td class="input"><input id="password" name="password" type="password" class="easyui-textbox" tabindex="1"/></td>
		</tr>
	</table>
</article>
</section>
<footer class="copyright">Copyright &copy;2014-2017 Joinway Limit. All Rights Reserved</footer>
</body>
</html>

